package com.yicoollxing.util;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class BigDecimalUtil {
   
	private BigDecimalUtil(){
		
	}
	
	public static BigDecimal add(Double v1,Double v2){
		BigDecimal b1=new BigDecimal(Double.toString(v1));
		BigDecimal b2=new BigDecimal(Double.toString(v2));
		return b1.add(b2);
	}
	
	public static BigDecimal sub(Double v1,Double v2){
		BigDecimal b1=new BigDecimal(Double.toString(v1));
		BigDecimal b2=new BigDecimal(Double.toString(v2));
		return b1.subtract(b2);
	}
	
	public static BigDecimal mul(Double v1,Double v2){
		BigDecimal b1=new BigDecimal(Double.toString(v1));
		BigDecimal b2=new BigDecimal(Double.toString(v2));
		return b1.multiply(b2);
	}
	
	public static BigDecimal div(Double v1,Double v2){
		BigDecimal b1=new BigDecimal(Double.toString(v1));
		BigDecimal b2=new BigDecimal(Double.toString(v2));
		return b1.divide(b2, 2, RoundingMode.HALF_UP);  //保留两位小数，并四舍五入
	}
}
